package com.hippo.core.core.manager

import android.content.Context
import android.os.Environment
import java.io.File

object FileManager  {



    @JvmStatic
    private fun getPublicRootDir(context: Context): String {
        return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).path+"/hippo"
    }

    @JvmStatic
    fun getRootPath(context: Context): String {
        return getPublicRootDir(context)
    }

    /**
     * 缓存根目录
     */
    @JvmStatic
    private fun getCacheRootDir(context: Context): String {
        return context.externalCacheDir?.path ?: context.cacheDir.path
    }

    @JvmStatic
    fun getNaviPath(context: Context): String{
        var path = getCacheRootDir(context) +"/navi"
        var file = File(path)
        if(!file.exists()){
            file.mkdirs()
        }
        return path
    }



    @JvmStatic
    fun getCrashPath(context: Context): String{
        var path = getCacheRootDir(context) +"/crash"
        var file = File(path)
        if(!file.exists()){
            file.mkdirs()
        }
        return path
    }


    @JvmStatic
    fun getTempPath(context: Context): String{
        var path = getCacheRootDir(context) +"/temp"
        var file = File(path)
        if(!file.exists()){
            file.mkdirs()
        }
        return path
    }


    @JvmStatic
    fun getDownloadPath(context: Context): String{
        var path = getCacheRootDir(context) +"/download"
        var file = File(path)
        if(!file.exists()){
            file.mkdirs()
        }
        return path
    }


    @JvmStatic
    fun getLogPath(context: Context): String{
        var path = getCacheRootDir(context) +"/logs"
        var file = File(path)
        if(!file.exists()){
            file.mkdirs()
        }
        return path
    }

    @JvmStatic
    fun getConfigPath(context: Context): String{
        var path = context.filesDir.path +"/configs"
        var file = File(path)
        if(!file.exists()){
            file.mkdirs()
        }
        return path
    }

}